<div class="grid_12">
    <div class="box round first fullpage">
        <h2>Cập nhật sản phẩm</h2>
        <div class="block ">
        <?php if(!empty($this->message)){?>
            <script>
            $(function(){
                $("#code-element").append("<span class='error'><?=$this->message?></span>");
                setInterval(function(){
                    $(".message").fadeOut("slow");
                    $(".message").remove();
                },5000);
            })
            </script>
            <?php }?>
            <?=$this->form?>
        </div>
    </div>
</div>

<script>
    $(function(){
       createEditor("description");
       
       //create thumb nail
       $("#image").change(function(e){
            // get image
            var thisObj = $(this);
            var url = URL.createObjectURL(e.target.files[0]);
            var img = new Image();
            
            var canvas = document.createElement("canvas");
            canvas.setAttribute("class","thumb");
            
            var ctx = canvas.getContext('2d');
            img.onload = function() {
                var h = 200, per = img.width/img.height;
                var w = h*per;
                canvas.height = h;
                canvas.width = w;
                $(".thumb").remove();
                thisObj.parent().append(canvas);
                ctx.drawImage(img, 0, 0,w ,h);    
            }
            img.src = url;   
       })
       
       <?php if(!empty($this->thumb)){?>
       $("#image").parent("dd")
                  .append("<img class='thumb' src='<?=$this->baseUrl("images/product/thumb/$this->thumb")?>'/>");
       <?php }?>
    });
</script>